package com.szrt.javaweb.ch01.dyn.spring;

import org.apache.ibatis.session.SqlSession;
import org.mybatis.spring.SqlSessionFactoryBean;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.mysql.jdbc.exceptions.jdbc4.MySQLSyntaxErrorException;

@Repository
public class ActorDaoImplBACKUP implements ActorDao {

	@Autowired
	private SqlSessionFactoryBean factory;
	
	
	/*@Autowired
	private SqlSessionTemplate factory;*/
	
	
	
	
	
	
	@Override
	public int insert(ActorEntity entity) throws Exception {
		SqlSession session=null;
		try {
			session = factory.getObject().openSession(false);
			ActorDao dao = session.getMapper(ActorDao.class);
			dao.insert(entity);
			
			//dao.insert2(entity);
			System.out.println("id="+entity.getId());
			return 0;
		} catch (MySQLSyntaxErrorException e) {

			throw new MySQLSyntaxErrorException();
		}
		
		
	}



	@Override
	public int insert2(ActorEntity entity) {
		// TODO Auto-generated method stub
		return 0;
	}

}
